package modele;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

@Entity
public class Tournoi {
	private long idTournoi;
	private String nom ;
	
	private Map<Integer, Equipe> listeEquipes;
	private Collection<Match> listeMatch;
	private String Etat;
	

	public Tournoi(){
		listeMatch = new ArrayList<Match>();
		listeEquipes = new HashMap<Integer, Equipe>();
		Etat = "A venir";
	}

	/** 
	 * Getters / Setters 
	 */
	
	public String getNom() {
		return nom;
	}
	public void setNom(String nom) {
		this.nom = nom;
	}
	public String getEtat() {
		return Etat;
	}
	public void setEtat(String etat) {
		Etat = etat;
	}
	
	@ManyToMany(targetEntity = Equipe.class,fetch=FetchType.EAGER)
	public Map<Integer, Equipe> getListeEquipe() {
		return listeEquipes;
	}
	public void addEquipe(Integer i, Equipe equipe){
		this.listeEquipes.put(i, equipe);
	}
	public void setListeEquipe(Map<Integer, Equipe> equipe){
		this.listeEquipes=equipe;
	}
	@OneToMany(fetch=FetchType.EAGER)
	public Collection<Match> getListeMatch() {
		return listeMatch;
	}
	public void addMatch(Match match){
		this.listeMatch.add(match);
	}
	public void setListeMatch(Collection<Match> matchs){
		this.listeMatch = matchs;
	}
	@Id
	@GeneratedValue
	public long getIdTournoi() {
		return idTournoi;
	}

	public void setIdTournoi(long idTournoi) {
		this.idTournoi = idTournoi;
	}
}
